package com.ysqcould.curriculum.service.impl;

import java.util.List;

import com.ysqcould.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ysqcould.curriculum.mapper.CourseTeacherMapper;
import com.ysqcould.curriculum.domain.CourseTeacher;
import com.ysqcould.curriculum.service.ICourseTeacherService;

/**
 * 课程教师Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-09-27
 */
@Service
public class CourseTeacherServiceImpl implements ICourseTeacherService 
{
    @Autowired
    private CourseTeacherMapper courseTeacherMapper;

    /**
     * 查询课程教师
     * 
     * @param id 课程教师主键
     * @return 课程教师
     */
    @Override
    public CourseTeacher selectCourseTeacherById(Long id)
    {
        return courseTeacherMapper.selectCourseTeacherById(id);
    }

    /**
     * 查询课程教师列表
     * 
     * @param courseTeacher 课程教师
     * @return 课程教师
     */
    @Override
    public List<CourseTeacher> selectCourseTeacherList(CourseTeacher courseTeacher)
    {
        return courseTeacherMapper.selectCourseTeacherList(courseTeacher);
    }

    /**
     * 新增课程教师
     * 
     * @param courseTeacher 课程教师
     * @return 结果
     */
    @Override
    public int insertCourseTeacher(CourseTeacher courseTeacher)
    {
        courseTeacher.setCreateTime(DateUtils.getNowDate());
        return courseTeacherMapper.insertCourseTeacher(courseTeacher);
    }

    /**
     * 修改课程教师
     * 
     * @param courseTeacher 课程教师
     * @return 结果
     */
    @Override
    public int updateCourseTeacher(CourseTeacher courseTeacher)
    {
        courseTeacher.setUpdateTime(DateUtils.getNowDate());
        return courseTeacherMapper.updateCourseTeacher(courseTeacher);
    }

    /**
     * 批量删除课程教师
     * 
     * @param ids 需要删除的课程教师主键
     * @return 结果
     */
    @Override
    public int deleteCourseTeacherByIds(Long[] ids)
    {
        return courseTeacherMapper.deleteCourseTeacherByIds(ids);
    }

    /**
     * 删除课程教师信息
     * 
     * @param id 课程教师主键
     * @return 结果
     */
    @Override
    public int deleteCourseTeacherById(Long id)
    {
        return courseTeacherMapper.deleteCourseTeacherById(id);
    }

    /**
     * 修改讲师状态
     * @param teacher
     * @return
     */
    @Override
    public int changeTeacherStatus(CourseTeacher teacher) {
        CourseTeacher courseTeacher = courseTeacherMapper.selectCourseTeacherById(teacher.getId());
        courseTeacher.setStatus(teacher.getStatus());
        courseTeacher.setUpdateTime(DateUtils.getNowDate());
        return courseTeacherMapper.updateCourseTeacher(courseTeacher);
    }

    /**
     * 课程讲师
     * @param userId
     * @return
     */
    @Override
    public List<CourseTeacher> selectList(Long userId) {
        CourseTeacher teacher=new CourseTeacher();
        teacher.setAsId(userId);
        List<CourseTeacher> courseTeachers = courseTeacherMapper.selectCourseTeacherList(teacher);
        return courseTeachers;
    }
}
